import request from '@/utils/request'

export function fetchList(data) {
  return request({
    url: '/backend/user',
    method: 'get',
    params: data
  })
}

export function getInfo(data) {
  return request({
    url: '/backend/user/user-detail',
    method: 'get',
    params: data
  })
}

export function updateUser(data) {
  return request({
    url: '/backend/user/' + data['id'],
    method: 'put',
    data
  })
}
// 更新用户状态
export function updateStatus(data) {
  return request({
    url: '/backend/user/change-status',
    method: 'get',
    params: data
  })
}
// 激活用户
export function activeStatus(data) {
  return request({
    url: '/backend/user/active-user',
    method: 'get',
    params: data
  })
}
// 修改密码
export function updatePass(data) {
  return request({
    url: '/adminuser/changepwd',
    method: 'post',
    data
  })
}

export function deleteUser(data) {
  return request({
    url: '/adminuser/' + data['id'],
    method: 'delete',
    data
  })
}

export function resetUser(data) {
  return request({
    url: '/backend/user/restpwd',
    method: 'post',
    data
  })
}

export function addUser(data) {
  return request({
    url: '/backend/user',
    method: 'post',
    data
  })
}

// 获取当前登录人信息
export function getUserInfo(data) {
  return request({
    url: '/backend/adminuser/' + data['id'],
    method: 'get',
    params: data
  })
}

// 获取分组详细信息
export function getGroupInfo(data) {
  return request({
    url: '/backend/authgroup/' + data['id'],
    method: 'get',
    params: data
  })
}

// 获取分组列表信息
export function fetchGroupList(data) {
  return request({
    url: '/backend/authgroup',
    method: 'get',
    params: data
  })
}

// 用户分组添加用户
export function addUserGroup(data) {
  return request({
    url: '/backend/authgroup',
    method: 'post',
    data
  })
}

// 用户分组修改用户
export function updateUserGroup(data) {
  return request({
    url: '/backend/authgroup/' + data['id'],
    method: 'put',
    data
  })
}

// 用户分组删除
export function deleteUserGroup(data) {
  return request({
    url: '/backend/authgroup/delgroup',
    method: 'get',
    params: data
  })
}
